<script setup>
import { ref } from 'vue';
import { REGISTER, LOGIN } from '@/router/routeMap'

const title = '重置密码'
const username = ref('')
const password = ref('')
const confirmPassword = ref('')

defineProps({
  onClickRegister: Function
})

const onClickRegisterWrap = () => {
  if (password.value !== confirmPassword.value) return
  onClickRegister({ username, password })
}
</script>

<template>
  <el-form class="form-container" label-width="100px">
    <h1 class="caption">{{ title }}</h1>
    <el-form-item label="用户名：">
      <el-input v-model="username" />
    </el-form-item>
    <el-form-item label="新密码：">
      <el-input type="password" v-model="password" />
    </el-form-item>
    <el-form-item label="确认密码：">
      <el-input type="confirmPassword" v-model="confirmPassword" />
    </el-form-item>
    <el-form-item>
      <el-button class="button" type="primary" @click="onClickRegisterWrap">确认修改</el-button>
    </el-form-item>
    <el-form-item>
      <el-row justify="space-between" class="path-link">
        <router-link :to="REGISTER">立即注册</router-link>
        <router-link :to="LOGIN">立即登录</router-link>
      </el-row>
    </el-form-item>
  </el-form>
</template>

<style lang="sass" scoped>

.caption
  margin-bottom: 30px
  text-align: center

.form-container
  width: 30vw
  min-width: 400px
  margin: auto
  margin-top: 10vh
  .button
    width: 100%

.path-link
  width: 100%
  a
    font-size: 12px
    text-decoration: none
</style>